A computer system may use memory more or less efficiently. In general, a computer system uses memory more efficiently where there is a smaller ratio of overhead to payload data. The computer system uses memory less efficiently as the ratio of overhead to payload data increases. Payload data is useful data that is not merely structural. Overhead may take many different forms. Examples of overhead include, but are not limited to: structural overhead; padding; and unutilized fields.
As an example of structural overhead, consider an object myObject that is an instance of a class MyClass, i.e., an object of type MyClass. The object myObject includes a field myBoolean declared as a boolean primitive type. The value of the field myBoolean is payload data. The object myObject has associated structural overhead, including an object header that stores metadata such as the object's class, a unique identifier, status flags indicating whether the object is reachable and/or locked, etc. As the number of objects of type MyClass increases, the structural overhead that occupies memory also increases.
As an example of padding, consider multiple objects of type MyClass. A runtime environment may allocate memory for objects only in 8-byte increments. If the structural overhead and payload of each object of type MyClass occupies 7 bytes, then 1 byte of adjacent memory (“padding”) also will be occupied to store each object. As the number of objects of type MyClass increases, the padding that occupies memory also increases.
As an example of unutilized fields, consider a field myBoolean that is declared at runtime. The field (and any associated structural overhead and padding) occupies memory. However, if the field myBoolean is never used at runtime, that memory may be considered wasted. The field myBoolean may itself be viewed as overhead rather than payload.
Overhead may degrade a computer system's performance. If there is not enough memory to satisfy all the overhead along with other memory needs, the computer system may slow due to paging. In a cloud system with multiple tenants, a tenant with significant overhead may exceed its memory allotment. The cloud system may automatically provision more memory for the tenant, reducing memory available to other tenants. Additional provisioning may also incur additional hosting costs for the tenant. If multiple tenants exceed their memory allotments, the cloud system operator may incur costs (in time and money) expanding the cloud system's available resources.
The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section.